<!DOCTYPE html>
<html lang="zh">
<#
 include "head.html";
 #>
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    <#
     include "lefter.html";
     #>
    <!--End 左侧导航-->
    <!--头部信息-->
    <#
     include "header.html";
     #>
    <!--End 头部信息-->
    <!--页面主要内容-->
    <main class="lyear-layout-content">
      
      <div class="container-fluid">
        
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-body">
                
                <form method="post" action="#!" class="site-form">
                  <div class="form-group">
                    <label for="email">邮箱</label>
                    <input type="text" class="form-control" name="email" id="email" placeholder="输入邮箱">
                  </div>
                  <div class="form-group">
                    <label for="password">密码</label>
                    <input type="text" class="form-control" name="password" id="password" placeholder="输入密码">
                  </div>
                  <div class="form-group">
                    <label for="inactive">停用</label>
                    <select class="form-control" id="inactive" name="inactive" size="1">
                      <option value="F">否</option>
                      <option value="T">是</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label for="subCountLimit">HTTP限制数</label>
                    <input type="text" class="form-control" name="subCountLimit" id="subCountLimit" value="2">
                  </div>
                  <div class="form-group">
                    <label for="portCountLimit">TCP限制数</label>
                    <input type="text" class="form-control" name="portCountLimit" id="portCountLimit" value="0">
                  </div>
                  <button type="button" class="btn btn-primary" id="letsgo">保存</button>
                </form>
       
              </div>
            </div>
          </div>
          
        </div>
        
      </div>
      
    </main>
    <!--End 页面主要内容-->
  </div>
</div>

<#
 include "js.html";
 #>
<script src="js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="js/lightyear.js"></script>
<script type="text/javascript">
$('#letsgo').on('click', function(){
    if ($('#email').val() == '') {
        lightyear.notify('邮箱不能为空', 'danger', 1000);
        return;
    }
    if ($('#password').val() == '') {
        lightyear.notify('密码', 'danger', 1000);
        return;
    }
    lightyear.loading('show');
    $.ajax({
        type: "POST",
        url: "/openapi/v1/user/add",
        contentType: "application/json;charset=utf-8",
        data:JSON.stringify({"email":$('#email').val(),"password":$('#password').val(),"inactive":$('#inactive').val(),"subCountLimit":$('#subCountLimit').val(),"portCountLimit":$('#portCountLimit').val()}),
        dataType: "json",
        success:function (message) {
            lightyear.loading('hide');
            if (message.sta == 0) {
                console.log(message.obj);
                // lightyear.notify('登陆成功，页面即将自动跳转~', 'success', 1000);
                location.href = "users?utm_source=/users_add";
            } else {
                lightyear.notify(message.msg, 'danger', 1000);
            }
        },
        error:function (message) {
            lightyear.loading('hide');
            lightyear.notify('服务器错误，请稍后再试~', 'danger', 100);
        }
    });
});
</script>
</body>
</html>